{extend name="main" /}

{block name="body"}
{include file="breadcrumb" /}
<div class="layui-fluid">
    <div class="layui-card">
        <div class=" layui-card-header layuiadmin-card-header-auto">
            <form class="layui-form" method="get">
                <input type="hidden" name="bcid" value="{:input('bcid')}"><!--保留当前位置的bcid参数-->
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <a href="{:url('add')}" data-width="800px" data-height="600px" class="layui-btn xn_open" title="添加">
                            添加
                        </a>
                    </div>
                    <div class="layui-inline">
                        <a href="javascript:;" title="确认要删除吗？" class="layui-btn layui-btn-danger" id="deleteAll">
                            删除
                        </a>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label" style="width: 100px;">总计：{$count}</label>
                        <div class="layui-input-inline">
                            <input type="text" name="kw" class="layui-input" value="{$param.kw}">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <button class="layui-btn">
                            <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                        </button>
                    </div>
                </div>
            </form>
        </div>
        <div class="layui-card-body">
            <table class="layui-table">
                <tr>
                    <th><b><input type="checkbox" id="selectAll"></b></th>
                    <th><b>ID</b></th>
                    <th><b>所属城市</b></th>
                    <th><b>机场名称</b></th>
                    <th><b>添加时间</b></th>
                    <th><b>操作</b></th>
                </tr>

                <tbody>
                {foreach name="list" item="vo"}
                <tr>
                    <td><input type="checkbox" name="ids[]" value="{$vo.id}" class="checkids"></td>
                    <td>{$vo.id}</td>
                    <td>{$vo.cityname}</td>
                    <td>{$vo.name}</td>
                    <td>{$vo.create_time}</td>
                    <td>
                        <a href="{:url('edit',array('id'=>$vo['id']))}" data-width="800px" data-height="600px" title="编辑" class="layui-btn layui-btn-normal layui-btn-xs xn_open">
                            <i class="layui-icon layui-icon-edit"></i>编辑
                        </a>
                        <a href="{:Url('delete',array('id'=>$vo['id']))}" title="确认要删除吗？" class="layui-btn layui-btn-danger layui-btn-xs xn_delete">
                            <i class="layui-icon layui-icon-delete"></i>删除
                        </a>
                    </td>
                </tr>
                {/foreach}
                </tbody>
            </table>
        </div>
    </div>
    <div class="pages">
        {$list|raw}
    </div>
</div>
{/block}

{block name="js"}
<script>

    $(function() {
        var $selectAll = $("#selectAll");
        $selectAll.click(function() {
            if ($selectAll.prop("checked") == true) {
                $('.checkids').prop("checked", true);
            } else {
                $('.checkids').prop("checked", false);
            }
        });

        $("#deleteAll").click(function(){
            layer.confirm('确认删除选定内容吗?', {icon: 3, title:'操作提示'}, function(index){
                var ids = [];
                $('.checkids:checked').each(function(index,obj){
                    ids.push(obj.value);
                });
                $.get("{:Url('deleteAll')}?ids="+ids,function(data){
                    layer.msg(data.msg, {
                    time: 1000 
                    }, function(){
                    location.reload();
                    }); 
                });
            });
        });
    });


</script>
{/block}